package com.honglang.module.user.action;

import java.util.Map;

import com.honglang.common.tools.Constants;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class AdminAuthorizationInterceptor extends AbstractInterceptor {
   /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String intercept(ActionInvocation invocation) throws Exception{
	   
	   Map<?, ?> session=invocation.getInvocationContext().getSession();
	   String username=(String) session.get(Constants.USERNAME_KEY);
	   Integer role = (Integer)session.get(Constants.Role);
	   if(null!= username && !username.equals("") && null != role && role == Constants.Administrator ){
		   return invocation.invoke();
	   }
	   else{
		   return "adminLogin";
	   }
   }
}
